<?php
session_start();
include(dirname(dirname(__FILE__))."/functions/inc/util.inc.php");
include(dirname(dirname(__FILE__))."/functions/inc/mydb.inc.php");
include(dirname(dirname(__FILE__))."/functions/inc/seguridad.php");
include(dirname(dirname(__FILE__))."/entidades/color.class.php");


$db = new mydb();
$color = new color();
$_SESSION["campos"]=$_POST;

$busqueda_color=$db->consulta("SELECT * 
                               FROM color 
                               WHERE color_eliminado = 0 
                               AND color_nombre = '{$_POST["agregarColor"]}'");

if(count($busqueda_color)==0){
$color->setcolor_nombre($_POST["agregarColor"]);
$color->add();

    unset($_SESSION["campos"]);

    header("Location:/index.php?acc=".$_POST["acc"]."&msg=1"); 
}
else
{
     unset($_SESSION["campos"]);
    header("Location:/index.php?acc=".$_POST["acc"]."&msg=2"); 
}
?>
